// components/calendar/header/index.js
import properties from '../props/header'

const defaultWeekDays = ['日', '一', '二', '三', '四', '五', '六']

Component({
  properties,

  data: {
    weekdays: defaultWeekDays,
  },

  created() {
    this.initWeekDay();
  },

  methods: {
    initWeekDay() {
      const defaultWeeks = ['日', '一', '二', '三', '四', '五', '六'];
      const firstDayOfWeek = this.data.firstDayOfWeek || 0;
      this.setData({
        weekdays: [
          ...defaultWeeks.slice(firstDayOfWeek, 7),
          ...defaultWeeks.slice(0, firstDayOfWeek),
        ],
      });
    },

    onClickSubtitle(event) {
      this.triggerEvent('click-subtitle', event);
    },
  }
})
